import { DailyListNormal } from "./DailyListNormal";
import { ObjCreate } from "../../common/ObjCreate";
import { Language } from "../../../../../extend/language/Language";
import { ImagesConst } from "../../../resource/ImagesConst";
import { DailyCopyGradeReward } from "../reward/DailyCopyGradeReward";
import { DailyCopyGradeTargetPane } from "../reward/DailyCopyGradeTargetPane";
import { DailyCopyGradeItem } from "../item/DailyCopyGradeItem";
import { CopyConfig } from "../../../resource/CopyConfig";
import { ObjectPool } from "../../../../../com/gengine/utils/pools/ObjectPool";
import { ItemData } from "../../../resource/info/ItemData";
type int = number;
//class DailyCopyGradeList
    
    export  class DailyCopyGradeList extends DailyListNormal
    {
        constructor()
        {
            super();
            return;
        }

        protected /* override */ initUI(): void
        {
            super.initUI();
            _bg.width = 445;
            _bg.height = 360;
            _scrollPane.width = _listWidth - 5;
            this.createTargetPanel();
            ObjCreate.createLabel(Language.getString(90111), 2, 370, 650, 20, flash.text.TextFormatAlign.LEFT, this, false, 457005);
            return;
        }

        protected /* override */ initWidth(): void
        {
            _titleWidth = 460;
            _listWidth = 440;
            _listHeight = 325;
            return;
        }

        protected /* override */ createTitleBar(): void
        {
            ObjCreate.createLabel(Language.getString(90112), 0, 5, 120, 20, flash.text.TextFormatAlign.CENTER, this, true, 16646089);
            ObjCreate.createLabel(Language.getString(90113), 120, 5, 40, 20, flash.text.TextFormatAlign.CENTER, this, true, 16646089);
            ObjCreate.createLabel(Language.getString(90114), 160, 5, 75, 20, flash.text.TextFormatAlign.CENTER, this, true, 16646089);
            ObjCreate.createLabel(Language.getString(90115), 235, 5, 80, 20, flash.text.TextFormatAlign.CENTER, this, true, 16646089);
            ObjCreate.createLabel(Language.getString(90116), 315, 5, 85, 20, flash.text.TextFormatAlign.CENTER, this, true, 16646089);
            ObjCreate.createLabel(Language.getString(90117), 400, 5, 45, 20, flash.text.TextFormatAlign.CENTER, this, true, 16646089);
            ObjCreate.createBg(0, 25, 445, 2, this, ImagesConst.SplitLine);
            return;
        }

        protected /* override */ createAwardList(): void
        {
            this._copyGradeAwardsPanel = new DailyCopyGradeReward(211, 112);
            this._copyGradeAwardsPanel.x = 450;
            this._copyGradeAwardsPanel.y = 0;
            addChild(this._copyGradeAwardsPanel);
            return;
        }

        protected createTargetPanel(): void
        {
            this._copyGradeTargetPanel = new DailyCopyGradeTargetPane(211, 244);
            this._copyGradeTargetPanel.x = 450;
            this._copyGradeTargetPanel.y = 116;
            addChild(this._copyGradeTargetPanel);
            return;
        }

        protected /* override */ onItemListClickHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            var loc1=arg1.target as DailyCopyGradeItem;
            if (loc1 && !(loc1 == _lastItem)) 
            {
                loc1.mouseDown(true);
                this._copyGradeAwardsPanel.updateGradeData(loc1.gradeInfo);
                if (_lastItem) 
                {
                    _lastItem.mouseDown(false);
                }
                _lastItem = loc1;
            }
            return;
        }

        public /* override */ updateData(arg1: Array<any>, arg2: int, arg3: int=0): void
        {
            var loc2=0;
            var loc3=0;
            var loc4=null;
            var loc5=null;
            var loc1=_bodySprite.selectIndex;
            dispose();
            if (arg1 != null) 
            {
                loc3 = arg1.length;
                while (loc2 < loc3) 
                {
                    if ((loc4 = arg1[loc2]) != null) 
                    {
                        if (CopyConfig.instance.getInfoByCode(loc4.copyCode)) 
                        {
                            (loc5 = ObjectPool.getObject(DailyCopyGradeItem)).updateGradeData(loc4);
                            _bodySprite.addItem(loc5);
                            if (loc2 == loc1) 
                            {
                                this._copyGradeAwardsPanel.updateGradeData(loc4);
                                loc5.mouseDown(true);
                                _lastItem = loc5;
                            }
                        }
                    }
                    ++loc2;
                }
            }
            this._copyGradeTargetPanel.updateTargetData();
            _bodySprite.redraw();
            _scrollPane.refreshPane();
            _scrollPane.update();
            this.selectedItemByType(arg3);
            return;
        }

        protected /* override */ selectedItemByType(arg1: int): void
        {
            var loc1=null;
            var loc2=0;
            var loc3=null;
            loc2 = 0;
            while (loc2 < _bodySprite.length) 
            {
                if ((loc3 = _bodySprite.getItemAt(loc2) as DailyCopyGradeItem) && loc3.gradeInfo.copyCode == arg1) 
                {
                    loc1 = loc3;
                    break;
                }
                ++loc2;
            }
            if (loc1 && !(loc1 == _lastItem)) 
            {
                loc1.mouseDown(true);
                this._copyGradeAwardsPanel.updateGradeData(loc1.gradeInfo);
                if (_lastItem) 
                {
                    _lastItem.mouseDown(false);
                }
                _lastItem = loc1;
            }
            return;
        }

        public onGetRewardRes(arg1: ItemData): void
        {
            this._copyGradeTargetPanel.onGetRewardRes(arg1);
            return;
        }

        /* internal */ /* var */_copyGradeAwardsPanel: DailyCopyGradeReward;

        /* internal */ /* var */_copyGradeTargetPanel: DailyCopyGradeTargetPane;
    }
